- /* scfcpown.cpp by K.Tsuru */
- // function ID = 9103
- /********************************
- SComplex class
- It returns z^n.
- *********************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SComplex Cpow(const SComplex& z, int n){
- SComplex y(1.0), r;
- if( z.IsZero(9103) ){// 0^n
- SNManager::SetError(SNManager::DOMAIN_ERR, "Cpow z=0", 9103);
- }
- if(n == 0) return y; // 1.0
-
- if(n < 0){
- r = y/z; // y = 1, "1/z" is an error.
- n = -n;
- }else r = z;
-
- while(1){
- if(n % 2) y *= r;
- n /= 2;
- if( !n ) break;
- r *= r;
- }
- return y;
- }
scfcpown.cpp : last modifiled at 2015/06/29 16:18:10(570 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:09 (Fri Oct 06 15:27:09 2017).